package org.dev.vlp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 动态-图片表
 * @TableName vlp_moment_image
 */
@TableName(value ="vlp_moment_image")
@Data
@Builder
@AllArgsConstructor //全参构造函数
@NoArgsConstructor
public class MomentImage implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long momImgId;

    /**
     * 动态id
     */
    private Long momentId;

    /**
     * 图片地址
     */
    private String url;

    /**
     * 宽
     */
    private Integer width;

    /**
     * 高
     */
    private Integer height;

    /**
     * 创建时间
     */
    private Date gmtCreate;

    /**
     * 更新时间
     */
    private Date gmtModified;

    private Integer isDeleted;

    @TableField(exist = false)
    private String images;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public MomentImage(Long momentId,String url,Integer width,Integer height){
        this.momentId=momentId;
        this.url=url;
        this.width=width;
        this.height=height;
        this.gmtCreate=new Date();
        this.gmtModified=new Date();
        this.isDeleted=0;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        MomentImage other = (MomentImage) that;
        return (this.getMomImgId() == null ? other.getMomImgId() == null : this.getMomImgId().equals(other.getMomImgId()))
            && (this.getMomentId() == null ? other.getMomentId() == null : this.getMomentId().equals(other.getMomentId()))
            && (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
            && (this.getWidth() == null ? other.getWidth() == null : this.getWidth().equals(other.getWidth()))
            && (this.getHeight() == null ? other.getHeight() == null : this.getHeight().equals(other.getHeight()))
            && (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
            && (this.getGmtModified() == null ? other.getGmtModified() == null : this.getGmtModified().equals(other.getGmtModified()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getMomImgId() == null) ? 0 : getMomImgId().hashCode());
        result = prime * result + ((getMomentId() == null) ? 0 : getMomentId().hashCode());
        result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
        result = prime * result + ((getWidth() == null) ? 0 : getWidth().hashCode());
        result = prime * result + ((getHeight() == null) ? 0 : getHeight().hashCode());
        result = prime * result + ((getGmtCreate() == null) ? 0 : getGmtCreate().hashCode());
        result = prime * result + ((getGmtModified() == null) ? 0 : getGmtModified().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", momImgId=").append(momImgId);
        sb.append(", momentId=").append(momentId);
        sb.append(", url=").append(url);
        sb.append(", width=").append(width);
        sb.append(", height=").append(height);
        sb.append(", gmtCreate=").append(gmtCreate);
        sb.append(", gmtModified=").append(gmtModified);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}